package com.example.orderservice.controller;

import com.example.communservice.entity.Order;
import com.example.orderservice.service.OrderService;
import com.example.orderservice.service.QuartzService;
import org.quartz.Scheduler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;
    @Autowired
    private QuartzService quartzService;


    @GetMapping("/getUserOrder")
    public Order getUserOrder(@RequestParam Integer userId){
        return orderService.getUserOrder(userId);
    }

    @GetMapping("/testQuartz")
    public String testQuartz(){
        quartzService.start("测试定时任务","0/10 * * * * ? *");
        return "将自动执行每10秒定时任务，请前往控制台查看";
    }
}
